﻿package mortal.game.view.forging.view
{
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.display.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.forging.data.*;

    public class GemItem extends BaseItem
    {
        private var _disabledBg:ScaleBitmap;
        private var _lightBg:ScaleBitmap;
        private var _isUseable:Boolean;
        private var _levelBg:GImageBitmap;
        private var _gemLevel:GTextFiled;
        private var _gemStrenLevel:GTextFiled;
        private var _posInEquip:int;

        public function GemItem()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.source = GlobalClass.getBitmap(ImagesConst.GemStrengthen);
            this._disabledBg = UIFactory.bg(0, 0, width, height, this, ImagesConst.PackDisable);
            this._disabledBg.visible = false;
            this._levelBg = UIFactory.gImageBitmap(ImagesConst.Forging_LevelMark, 0, 0, this);
            this._levelBg.visible = false;
            this._gemLevel = UIFactory.gTextField("4", 0, -4, 30, 20, this);
            this._gemLevel.visible = false;
            var _loc_1:* = GlobalStyle.textFormatHuang2;
            _loc_1.size = 14;
            this._gemStrenLevel = UIFactory.gTextField("", 20, 22, 30, 22, this, _loc_1);
            this._gemStrenLevel.visible = false;
            this._lightBg = UIFactory.bg(0, 0, this.width, this.height, this, ImagesConst.selectedBg);
            this._lightBg.visible = false;
            return;
        }// end function

        public function set isOpened(param1:Boolean) : void
        {
            if (param1)
            {
                this.source = GlobalClass.getBitmap(ImagesConst.GemStrengthen);
            }
            else
            {
                this.source = GlobalClass.getBitmap(ImagesConst.StrengOpenBg);
            }
            return;
        }// end function

        public function set isSelected(param1:Boolean) : void
        {
            if (param1)
            {
                this._bitmap.filters = [FilterConst.colorGlowFilter(16776960)];
            }
            else
            {
                this._bitmap.filters = [];
            }
            return;
        }// end function

        public function set isUseable(param1:Boolean) : void
        {
            if (param1)
            {
                this._disabledBg.visible = false;
                this._isUseable = true;
                this.mouseEnabled = true;
            }
            else
            {
                this._disabledBg.visible = true;
                this._isUseable = false;
                this._disabledBg.width = _width - _paddingLeft * 2;
                this._disabledBg.height = _height - _paddingTop * 2;
                this._disabledBg.x = _paddingLeft;
                this._disabledBg.y = _paddingTop;
            }
            return;
        }// end function

        public function set isShowLevel(param1:Boolean) : void
        {
            if (param1)
            {
                this._levelBg.visible = true;
                this._gemLevel.visible = true;
                this._gemLevel.text = "" + itemData.itemInfo.itemLevel;
            }
            else
            {
                this._levelBg.visible = false;
                this._gemLevel.visible = false;
            }
            return;
        }// end function

        public function set isShowStrengLevel(param1:Boolean) : void
        {
            if (param1)
            {
                this._gemStrenLevel.visible = true;
                this._gemStrenLevel.text = "+" + itemData.itemInfo.itemLevel;
                if (_itemData.itemInfo.itemLevel == ForgingConst.GemMaxLevel)
                {
                    this._gemStrenLevel.x = 13;
                }
            }
            else
            {
                this._gemStrenLevel.visible = false;
            }
            return;
        }// end function

        public function get isUseable() : Boolean
        {
            return this._isUseable;
        }// end function

        public function set isLight(param1:Boolean) : void
        {
            if (param1)
            {
                this._lightBg.visible = true;
            }
            else
            {
                this._lightBg.visible = false;
            }
            return;
        }// end function

        public function addShakeLight() : void
        {
            EffectManager.glowFilterUnReg(this);
            EffectManager.glowFilterReg(this, null, 1, 10, 0, 4);
            return;
        }// end function

        public function clear() : void
        {
            itemData = null;
            this.source = GlobalClass.getBitmap(ImagesConst.GemStrengthen);
            this.isShowLevel = false;
            return;
        }// end function

        public function get posInEquip() : int
        {
            return this._posInEquip;
        }// end function

        public function set posInEquip(param1:int) : void
        {
            this._posInEquip = param1;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this.name = "";
            this._disabledBg.dispose(param1);
            this._lightBg.dispose(param1);
            this._levelBg.dispose(param1);
            this._gemLevel.dispose(param1);
            this._gemStrenLevel.dispose(param1);
            this._disabledBg = null;
            this._lightBg = null;
            this._levelBg = null;
            this._gemLevel = null;
            this._gemStrenLevel = null;
            this._posInEquip = 0;
            return;
        }// end function

    }
}
